package com.ddwl.wallet.controller;

import com.ddwl.common.annotation.Auth;
import com.ddwl.common.constant.BaseEnum;
import com.ddwl.common.controller.BaseController;
import com.ddwl.schema.bo.base.PageBo;
import com.ddwl.schema.bo.wallet.WithdrawChannelConfAddBo;
import com.ddwl.schema.bo.wallet.WithdrawChannelConfEnableBo;
import com.ddwl.schema.bo.wallet.WithdrawChannelConfUpdateBo;
import com.ddwl.schema.vo.base.PageVo;
import com.ddwl.schema.vo.base.RestVo;
import com.ddwl.schema.vo.wallet.WithdrawChannelConfVo;
import com.ddwl.wallet.service.WithdrawChannelConfService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @Author hemiaojun
 * @Date 2021/6/23 17:34
 */
@RequestMapping("/withdrawChannelConf")
@RestController
@Api("提现渠道配置")
public class WithdrawChannelConfController extends BaseController {


    @Resource
    private WithdrawChannelConfService withdrawChannelConfService;


    @PostMapping("/add")
    @Auth(product = BaseEnum.ProductEnum.CONSOLE)
    @ApiOperation("新增提现渠道")
    private RestVo add(@Valid @RequestBody WithdrawChannelConfAddBo bo){
        withdrawChannelConfService.add(bo);
        return RestVo.ok();
    }

    @PostMapping("/update")
    @Auth(product = BaseEnum.ProductEnum.CONSOLE)
    @ApiOperation("修改提现渠道")
    private RestVo update(@Valid @RequestBody WithdrawChannelConfUpdateBo bo){
        withdrawChannelConfService.update(bo);
        return RestVo.ok();
    }

    @PostMapping("/enable")
    @Auth(product = BaseEnum.ProductEnum.CONSOLE)
    @ApiOperation("启用/禁用提现渠道")
    private RestVo enable(@Valid @RequestBody WithdrawChannelConfEnableBo bo){
        withdrawChannelConfService.enable(bo);
        return RestVo.ok();
    }

    @PostMapping("/page")
    @Auth(product = BaseEnum.ProductEnum.CONSOLE)
    @ApiOperation("提现渠道分页")
    private RestVo<PageVo<WithdrawChannelConfVo>> page(@Valid @RequestBody PageBo bo){
        return RestVo.ok(withdrawChannelConfService.page(bo));
    }


}
